package xyz.wanwanwan.www.hrm.fallback;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import xyz.wanwanwan.www.hrm.CourseDoc;
import xyz.wanwanwan.www.hrm.query.CourseQuery;
import xyz.wanwanwan.www.hrm.searchcourse.client.SearchCourseClient;
import xyz.wanwanwan.www.hrm.util.AjaxResult;

@Component
@Slf4j
public class SearchCourseClientFallbackFactory implements FallbackFactory<SearchCourseClient> {
    @Override
    public SearchCourseClient create(Throwable throwable) {
        return new SearchCourseClient() {
            @Override
            public AjaxResult saveDoc(@RequestBody CourseDoc courseDoc) {
                throwable.printStackTrace();
                log.error("es保存课程失败了");
                return AjaxResult.me().setSuccess(false).setMessage("es保存课程失败了");
            }

            @Override
            public AjaxResult delDoc(Long id) {
                throwable.printStackTrace();
                log.error("es删除课程失败了");
                return AjaxResult.me().setSuccess(false).setMessage("es删除课程失败了");
            }

            @Override
            public AjaxResult queryCourse(CourseQuery query) {
                throwable.printStackTrace();
                log.error("es查询前端课程类型失败了");
                return AjaxResult.me().setSuccess(false).setMessage("es查询前端课程类型失败了");
            }
        };
    }
}
